package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
public class UserController {

    @Autowired
    RpcClientProxy rpcClientProxy;

    @GetMapping("{id}")
    public User get(@PathVariable("id") Integer id){
        IUserService userService =rpcClientProxy.createProxy(IUserService.class);
        User user = userService.getById(id);
        return user;
    }
}
